﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using WeChat.CMS.Controllers;

namespace WeChat.CMS.Foods
{
    [Authorize]
    [RemoteService(Name = "Food")]
    [ControllerName("Food")]
    [Route("api/app/food")]
    public  class FoodController:CMSController
    {
        private readonly IFoodAppService _foodAppService;

        public FoodController(IFoodAppService foodAppService)
        {
            this._foodAppService = foodAppService;
        }

        [HttpPost]
        public async Task<bool> CreateAsync(FoodCreationDto input)
        {
            return await _foodAppService.CreateAsync(input);
        }


        [HttpDelete]
        [Route("{id}")]
        public async Task<bool> DeleteAsync(Guid id)
        {
            return await _foodAppService.DeleteAsync(id);
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<FoodDto> GetAsync(Guid id)
        {
            return await _foodAppService.GetAsync(id);
        }

        [HttpPut]
        public async Task<bool> UpdateAsync(FoodUpdateDto input)
        {
            return await _foodAppService.UpdateAsync(input);
        }

        [HttpGet]
        public async Task<PagedResultDto<FoodDto>> GetListAsync(FoodPagedListDto input)
        {
            return await _foodAppService.GetListAsync(input);
        }

        [HttpGet]
        [Route("all")]
        public async Task<List<FoodDto>> GetAllListAsync()
        {
            return await _foodAppService.GetAllListAsync();
        }

    }
}
